home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / MacApp Documentation / MacApp.TECH$ Archives / 1990 / Nov 90 / MacApp.Tech$ 11⁄23⁄90 / 2387-Re Performance Tools-Nov90 next >
Encoding:
Text File  |  1991-03-06  |  2.7 KB  |  81 lines  |  [TEXT/GEOL]

  1. Item    8687747                         16-Nov-90        23:44PST
  2.  
  3. From:   GER.XSE0067                     Germany - Norbert Lindenberg,IDV
  4.  
  5. To:     AUST0134                        Jam Software Sydney,IVR
  6.         MACAPP.TECH$                    MacApp Technical
  7.  
  8. Sub:    Re: Performance Tools
  9.  
  10. When I tried to use the MacApp performance tools, I also had the impression
  11. that they are pretty useless - they seem only to work with -debug versions, and
  12. I am interested in the performance of the final (-nodebug) version only.
  13.  
  14. My solution was to override TApplication.PerformCommand with the following
  15. method:
  16.  
  17. {$S ARes}
  18. PROCEDURE TMacWebApplication.PerformCommand(command: TCommand); override;
  19. {$IFC qPerform and not qDebug}
  20.    var thePerfGlobals: TP2PerfGlobals; { ??? must not be in the final version }
  21.    procedure OpenPerf; { ??? must not be in the final version }
  22.    var aKeyMap: KeyMap;
  23.    begin
  24.    thePerfGlobals := nil;
  25.    GetKeys(aKeyMap);
  26.    if aKeyMap[$3b] then begin { control char pressed }
  27.    if not InitPerf(thePerfGlobals, 2, 2, true, true, 'CODE', 0, '', false, 0,
  28. 0, 0)
  29.    then thePerfGlobals := nil; { just to be sure }
  30.    if (thePerfGlobals <> NIL) & PerfControl(thePerfGlobals, true) then { fine!
  31. };
  32.    end;
  33.    end;
  34.    procedure ClosePerf; { ??? must not be in the final version }
  35.    begin
  36.    if thePerfGlobals <> NIL then begin
  37.    FailOSErr(PerfDump(thePerfGlobals, 'Perform.out', false, 0));
  38.    TermPerf(thePerfGlobals);
  39.    thePerfGlobals := NIL;
  40.    end;
  41.    end;
  42.    procedure HandleFailure(error: OSErr; message: Longint);
  43.    begin
  44.    gEventLevel := gEventLevel -1;
  45.    ClosePerf;
  46.    end;
  47.    VAR fi: FailInfo;
  48. {$ENDC}
  49.    BEGIN
  50. {$IFC qPerform and not qDebug}
  51.    OpenPerf;
  52.    CatchFailures(fi, HandleFailure);
  53.    gEventLevel := gEventLevel +1; { prevent segment unloading }
  54.    inherited PerformCommand(command);
  55.    Success(fi);
  56.    gEventLevel := gEventLevel -1;
  57.    ClosePerf;
  58. {$ELSEC}
  59.    inherited PerformCommand(command);
  60. {$ENDC}
  61.    END;
  62.  
  63. This allows you to get performance data about execution of of any command
  64. handled by a TCommand object simply by holding the control key when it is
  65. launched.
  66.  
  67. To use this method, you have to add the “Perf” unit to the “uses” declaration
  68. of the unit containing the method, and to build the application with “-nodebug
  69. -perform”. The order of the options is significant, as MABuildTool turns off
  70. performance measurement when it sees the -nodebug option.
  71.  
  72. You also may wish to fiddle with the arguments to InitPerf - see the
  73. “Performance Measurement Tools” chapter in the MPW Reference for details. To
  74. use the arguments as given above, I had to increase the MultiFinder partition
  75. of my application to 1.5MB (from 600KB).
  76.  
  77. Hope this helps.
  78.  
  79. -- Norbert
  80.  
  81.